<?php

class PublicAction extends CommonAction
{

    public function selectarea()
    {
        $post = $this->boxpost();
        //取列表
        $parentdiscrictid = intval($post['parentdiscrictid']);
        $M_District = D('District');
        $list = $M_District->get_child($parentdiscrictid);
        $isleaf = $list ? 0 : 1;
        $this->assign('canselect', $parentdiscrictid ? 1 : 0);
        $this->assign('list', $list);
        $this->assign('isleaf', $isleaf);
        //取路径
        $paths = $M_District->get_paths($parentdiscrictid);
        $this->assign('paths', $paths);
        $this->display();
    }

    public function logout()
    {
        //$this->jiedai_member_model = M($this->JDDB."Member",'');
        //$this->jiedai_member_model->where(array('id'=>$this->member['id']))->save(array('last_sessionid'=>''));
        M()->query("update " . $this->JDDB . "member set last_sessionid='' where id='{$this->member['id']}'");
        session('member', null);
        $this->redis_cache_connect();
        $this->redis_cache->delete('webcache_logined_' . session_id());
        $this->ajaxSuccess('您已安全退出');
    }

    public function verifyajaxcheck($verify = false)
    {
        if (!$verify) {
            if (!$verify = $this->_get('verify')) {
                if (!$verify = $this->_post('verify')) {
                    $boxpost = $this->boxpost();
                    if (!$verify = $boxpost['verify']) {
                        $this->ajaxError('验证码不能为空');
                    }
                }
            }
        }
        if ($this->verifycheck($verify)) {
            $this->ajaxcheck('verify', array('value' => $verify, 'valid' => true, 'msg' => ''));
            $this->ajaxSuccess('验证码正确');
        } else {
            $this->ajaxcheck('verify', array('value' => $verify, 'valid' => false, 'msg' => '验证码错误'));
            $this->ajaxError('验证码错误');
        }
    }

    public function boxverify()
    {
        $post = $this->boxpost();
        if (empty($post['action'])) {
            $post['action'] = '进行的操作需要验证码';
        }
        if (empty($post['todo'])) {
            $post['todo'] = 'top.re_load';
        }
        session('boxverifytodo', $post['todo']);
        $this->assign('action', $post['action']);
        $this->display();
    }

    public function boxverifycheck()
    {
        $postdata = $this->boxpost();
        if (!$this->verifycheck($postdata['verifycode'])) {
            $this->ajaxcheck('verify', array('value' => $verify, 'valid' => false, 'msg' => '验证码不正确'));
            $this->assign('errnotice', '验证码不正确');
            $this->assign('action', empty($postdata['action']) ? '进行的操作需要验证码' : $postdata['action']);
            $this->display('boxverify');
            return;
        }
        $this->ajaxcheck('verify', array('value' => $verify, 'valid' => true, 'msg' => ''));
        $this->javascript(session('boxverifytodo'));
    }
    public function verifysms()
    {
        //原smscode失效
        $this->ajaxcheck('smscode', array('value' => '', 'valid' => false, 'msg' => '手机验证码已失效'));
        $mobile = $this->_post('mobile');
        $notmember = !!$this->_post('notmember');
        $type = $this->_post('type');
        $code = $this->_post('code');
        if ($notmember == false) {
            $ajaxcheck_mobile = $this->ajaxcheck('mobile');
            if (!$ajaxcheck_mobile['valid'] || $mobile != $ajaxcheck_mobile['value']) {
                $this->ajaxError($ajaxcheck_mobile['msg']);
            }
        }
        $ajaxcheck_verify = $this->ajaxcheck('verify');
        if (!$ajaxcheck_verify['valid']) {
            $this->ajaxError($ajaxcheck_verify['msg']);
        }

        if ($code == 'webreg') {
            /*注册验证码为防止短信轰炸，1天2条，1个月3条 start*/
            $send_reg_timesbyday = S('send_reg_timesbyday_' . $mobile) ? S('send_reg_timesbyday_' . $mobile) : 1;
            $send_reg_timesbymonth = S('send_reg_timesbymonth_' . $mobile) ? S('send_reg_timesbymonth_' . $mobile) : 1;
            if ($send_reg_timesbyday > 2 || $send_reg_timesbymonth > 3) {
                $this->ajaxError('注册验证码发送次数超限，请联系客服进行处理');
            }
            $send_reg_timesbyday++;
            $send_reg_timesbymonth++;
            //缓存1天
            S('send_reg_timesbyday_' . $mobile, $send_reg_timesbyday, 3600 * 24);
            //缓存30天
            S('send_reg_timesbymonth_' . $mobile, $send_reg_timesbymonth, 3600 * 24 * 30);
            /*注册验证码为防止短信轰炸，1天2条，1个月3条 end*/
        }
        import('@.ORG.Util.SMS');
        $sent = $type == 'voice' ? SMS::buildvoiceverify($mobile) : SMS::buildverify($mobile);
        $success_msg = '验证码已发送至您的手机：' . $mobile . '<br><br>本次验证码序号：' . $sent . '<br><br>请查收验证码内容并输入至"短信验证"框内';
        $error_msg = '验证码发送失败（' . SMS::$errcode . '），请联系客服或重试';
        if ($type == 'voice') {
            $success_msg = '语音' . $success_msg;
            $error_msg = '语音' . $error_msg;
        }
        if ($sent) {
            // 重置图片验证码有效性
            //$this->ajaxcheck('verify',array('value'=>'','valid'=>false,'msg'=>'验证码不能为空'));
            $this->ajaxcheck('smscodebindmobile', array('value' => $mobile, 'valid' => true, 'msg' => ''));
            $this->ajaxSuccess($success_msg);
        } else {
            $this->ajaxError($error_msg);
        }
    }

    public function smsajaxcheck()
    {
        $smscode = $this->_post('smscode');
        if ($this->smscheck($smscode)) {
            $this->ajaxcheck('smscode', array('value' => $smscode, 'valid' => true, 'msg' => ''));
            $this->ajaxSuccess('手机验证码正确');
        } else {
            $this->ajaxcheck('smscode', array('value' => $smscode, 'valid' => false, 'msg' => '手机验证码错误'));
            $this->ajaxError('手机验证码错误');
        }
    }

    public function verifycode()
    {
        import('@.ORG.Util.Image');
        ob_end_clean();
        Image::buildImageVerify();
    }

    public function actset_mebgrade()
    {
        exit();
        $key = $this->_get('key', 'trim');
        if (get_client_ip() == '116.231.120.145' && $key == 'huhanping2014') {
            set_time_limit(0);
            $this->set_member_grade('', true);
            echo '全部会员积分计算成功';
        } else {
            echo '您访问的页面不存在';
        }
    }

    public function set_member_grade($memid, $isall = false)
    {
        if (!$memid && $isall == false) {
            return false;
        }
        if ($isall == false) {
            $this->count_total_integral($memid);
        } else {
            $all_tender_info = D('Loan_tender')->where(array('status' => 1))->group('memberid')->order('id desc')->select();
            foreach ($all_tender_info as $tender_mem) {
                $this->count_total_integral($tender_mem['memberid'], true);
            }
        }
        return true;
    }

    private function count_total_integral($mid, $all = false)
    {
        $tender_info = $this->M->table('loan_tender lt')->join('loan l on lt.loansn=l.loansn')->where(array('lt.memberid' => $mid, 'lt.status' => 1, 'lt.calc_integral' => 0))->field('lt.tendersn,lt.money,l.loanmonth,lt.timeadd')->order('lt.id asc')->select();

        $_model_Integral = D('Integral');
        foreach ($tender_info as $key => $val) {
            $integral = ceil($val['money'] * $val['loanmonth'] / 100);
            D('Common')->startTrans();
            $res = $_model_Integral->income($mid, 'add', 'tender', $val['tendersn'], $integral, '投标', $all ? $val['timeadd'] : '');
            if (!$res) {
                D('Common')->rollback();
                continue;
            }
            //更新投资记录以计算积分
            $res_ult = M('Loan_tender')->where(array('tendersn' => $val['tendersn']))->save(array('calc_integral' => 1));
            if (!$res_ult) {
                D('Common')->rollback();
                continue;
            }
            D('Common')->commit();
        }
        return true;
    }

    public function weixinimg()
    {
        $this->display('weixinimg');
    }

    public function profitcal()
    {
        $this->display();
    }

    public function cmpayres()
    {
        $this->assign('cmd', $this->_request('cmd'));
        $this->assign('protocol', $this->_request('protocol'));
        $this->display();
    }

    //钱多多首页链接下载到桌面
    public function down_desk()
    {
        header("Content-type:application/octet-stream;");
        header("Content-Disposition:attachment;filename=%E9%92%B1%E5%A4%9A%E5%A4%9A.url");
        readfile("desk.url");
    }

    //apk下载
    public function downapk()
    {
        //$url = 'http://static.'.DOMAIN_URI.'/appsource/jiedai_1_2.apk?v=1.2';
        header('LOCATION:/public/downqianapk.html');
        exit();
        $client_type = get_device_type();
        if ($client_type == 'ios') {
            $url = C('APP_LAST_URI_IOS');
        } else {
            $url = C('APP_LAST_URI_ANDROID');
        }
        $this->assign('url', $url);
        $this->display();
    }

    //apk下载
    public function downqianapk()
    {
        $store=$this->_get('v')?$this->_get('v'):'';
        $client_type = get_device_type();
        if ($client_type == 'ios') {
            if($store!=""){
                $url='https://itunes.apple.com/cn/app/id956383323';
            }else{
                $url = C('APP_QIAN_URI_IOS');
            }
            
        }elseif($client_type =='other') {
            $show="你需要使用移动设备才可下载。";
            $url="";
        }
        else{
            $url = C('APP_QIAN_URI_ANDROID');  
        }
        $this->assign('url', $url);
        $this->assign('show', $show);
        $this->display();
    }

    //律师声明
    public function lawstatement()
    {
        $this->display();
    }

    //签到(https与http故障，故在此调用member/registration)
    public function pub_registration()
    {
        R('Member/registration');
    }

    //投标须知
    public function tenderpro()
    {
        $type = $this->_get('type');
        if($type == 'investment'){
            //直投的投标须知
            $this->display("tenderpro_investment");
        }elseif($type == 'investment_duoduoyi') {
            //直投多多易借款服务协议
            $this->display("investment_duoduoyi");
        }elseif($type == 'investment_chedai') {
            //直投多多车借款服务协议
            $this->display("investment_chedai");
        }elseif($type == 'investment_duoduole'){
            //直投多多乐借款服务协议
            $this->display("investment_duoduole");
        }elseif($type == 'fengxiangaozhishu'){
            //风险告知书
            $this->display("tenderprotwo");
        }elseif($type == 'fengxiangaozhishu_jinjiaosuo'){
            //风险告知书(金交所)
            $this->display("tenderprotwo_jinjiaosuo");
        }elseif($type == 'zidongtoubiao'){
			//一键投标须知
            $this->display("zidongtoubiao");
		}elseif($type == 'zidongtoubiaoshouquanshu'){
            //一键投标授权书
            $this->display("zidongtoubiaoshouquanshu");
        }elseif($type == 'zhaizhuanfuwuxieyi'){
            //债权转让服务协议
            $this->display("zhaizhuanfuwuxieyi");
        }elseif($type == 'zhaizhuan_duoduoyi'){
            //债转多多易
            $this->display("zhaizhuan_duoduoyi");
        }elseif($type == 'zhaizhuan_chedai') {
            //债转车贷
            $this->display("zhaizhuan_chedai");
        }elseif($type == 'zhaizhuan_duoduole'){
            //债转多多乐
            $this->display("zhaizhuan_duoduole");
        }elseif($type == 'tenderpro_jinjiaosuo'){
            //债转多多贝（金交所）
            $this->display("tenderpro_jinjiaosuo");
        }elseif($type == 'chanpinhetong_jinjiaosuo'){
            //产品合同（金交所）
            $this->display("zhaizhuan_jinjiaosuo");
        }elseif($type == 'chanpinhetong_jinjiaosuo_piaoju'){
            //产品合同（金交所）-票据
            $this->display("chanpinhetong_jinjiaosuo_piaoju");
        }elseif($type == 'investment_chemi') {
            //车米借款协议
            $this->display("investment_chemi");
        } elseif ($type == 'investment_chemi_debx') {
            //车米借款协议
            $this->display("investment_chemi_debx");
        }elseif($type == 'zhaizhuan_debtforuser') {
            //债权转让服务协议，用户发起债权转让
            $this->display("zhaizhuan_debtforuser");
        }elseif($type == 'zhaizhuan_zhuanrangguize'){
            $this->display('zhaizhuan_zhuanrangguize');
        }elseif($type == 'investment_zhaizhuanfuwuxieyi'){
            //房产债转协议（cateid 22 loan_attribute 2）
            $this->display('investment_zhaizhuanfuwuxieyi');
        }elseif($type == 'package_autobidauthed'){
            //多多集投标授权书
            $this->display('package_autobidauthed');
        }elseif($type == 'autobid_authorize'){
            //自动投标
            $this->display('autobid_authorize');
        }elseif($type == 'electronic_signatures_authorize'){
            //电子签章授权委托书
            $this->display('electronic_signatures_authorize');
        } elseif ($type == 'zhaizhuan_overdue') {
            //逾期债权转让服务协议
            $this->display('zhaizhuan_overdue');
        } elseif ($type == 'zhanqi_debt') {
            //项目展期服务协议
            $this->display('zhanqi_debt');
        } elseif ($type == 'paytype_pro') {
            //兑付协议
            $this->display('paytype_pro');
        } elseif ($type == 'paytype_method') {
            //现金兑付方案
            $this->display('paytype_method');
        }elseif($type == 'paytype_pro_app'){
            //兑付协议
            $this->display('paytype_pro_app');
        }elseif($type == 'pressdebtlendfengxiangaozhishu'){
            //风险告知书-认购项目
            $this->assign('cli', $this->_get('cli'));
            $this->display("pressdebtlendfengxiangaozhishu");
        }elseif($type == 'pressdebtlendrengoufangan'){
            //认购方案-认购项目
            $this->assign('cli', $this->_get('cli'));
            $this->display("pressdebtlendrengoufangan");
        }elseif($type == 'pressdebtlendrengouxieyi'){
            //认购协议-认购项目
            $this->assign('cli', $this->_get('cli'));
            $this->display("pressdebtlendrengouxieyi");
        } else {
            //债转的投标须知
            $this->display();
        }

    }

    //查看兑付相关协议模板
    public function settlepro()
    {
        $type = $this->_get('type');
        if($type == 'zhaiquanzhuanrang'){
            $this->display("settle_zhaiquanzhuanrang");
        } elseif ($type == 'zhaiquanjieqing') {
            $this->display("settle_zhaiquanjieqing");
        } elseif ($type == 'guohu_luyangxinghuacun') { //合肥庐阳区杏花村镇桃花村房产过户协议
            //@todo 现修改为集成房产过户协议
            $this->display("guohu_luyangxinghuacun");
        } elseif ($type == 'guohu_integrate_supplement') { //房产过户集成协议补充协议
            $this->display("guohu_integrate_supplement");
        } elseif ($type == 'guohu_integral_underline_paymoney') { //房产过户集成线下支付金额
            $this->display("guohu_integral_underline_paymoney");
        } elseif ($type == 'guohu_integral_underline_paymoney_supplement') { //房产过户集成线下支付金额补充协议
            $this->display("guohu_integral_underline_paymoney_supplement");
        } elseif ($type == 'fangdiguohu') {// 海安房抵签约协议
            $this->display("fangdiguohu");
        }
    }

    //意见反馈
    public function feedback()
    {
        $tpl_domain_url = C('tmpl_parse_string');
        $input_max_length = 2000; //最多输入字数限制
        $input_default_val = '想对多多说什么？期待您的反馈。'; //输入框默认提示文字
        $content = $this->_post('content');
        if (!empty($content)) {
            //判断是否登陆
            $logined = $this->checkLogin(true);
            if ($logined === false) return $this->ajaxError('请先登陆！');
            if ($content == $input_default_val) return $this->ajaxError('请先输入您想要反馈的信息');

            $content_len = mb_strlen($content, 'utf-8');
            if ($content_len > $input_max_length) return $this->ajaxError("您输入的信息超过了指定字数限制！");
            $add_data = array(
                'mobile'    => $this->member['mobile'],
                'member_id' => $this->member['id'],
                'content'   => urldecode($content),
                'client_ip' => get_client_ip(),
                'atime'     => date('Y-m-d H:i:s')
            );
            $res = M($this->JDDB . 'feedback')->add($add_data);
            if ($res > 0) {
                return $this->ajaxSuccess('感谢您对我们提出的保贵意见!');
            } else {
                return $this->ajaxError('非常抱歉，您的意见反馈失败！请稍后重试或与客服联系');
            }
        }

        $this->assign('static_domain_url', $tpl_domain_url['_STATIC_']);
        $this->assign('input_max_length', $input_max_length);
        $this->assign('input_default_val', $input_default_val);
        $this->display();
    }

    public function shuangdanRule()
    {
        $this->display('christmasrule');
    }

    //年龄统计
    public function yearsold()
    {
        header("Content-type: text/html; charset=utf-8");
        $sql = "select (2014-birthDay) as nl,count(id) as years from qianduoduo.member_info where birthDay is not null and birthDay>1900 and birthDay<2014 group by birthDay order by nl asc";
        $list = M()->query($sql);
        $total = 0;
        foreach ($list as $k => $v) {
            $total += $v['years'];
        }
        $html = '';
        $html .= '<h2>钱多多投资人年龄分布</h2><h9>共' . $total . '有人进行了身份证信息登记</h9><hr>';
        $html .= '<table>';
        $html .= '<tr><td style="font-size:12px;width:40px;">年龄</td><td style="font-size:12px;width:50px;">人数</td><td style="font-size:12px;width:60px;text-align:right">比例</td><td></td></tr>';
        foreach ($list as $k => $v) {
            $p = sprintf("%1\$.2f", ($v['years'] / $total) * 100);
            $html .= '<td style="font-size:12px;">' . $v['nl'] . '岁</td><td style="font-size:12px;">' . $v['years'] . '人</td><td align="right" style="font-size:12px;">' . $p . '%</td><td style="font-size:12px;"><div style="width:' . ($v['years'] / 2) . 'px;background-color:#090;font-size:12px">&nbsp;</div></td></tr>';
        }
        $html .= '</table>';
        echo $html;
    }

    //手机短信获得APK下载链接
    public function getapplinksms()
    {
        $url = 'http://' . DOMAIN_URI . '/public/downapk.html';
        $mobile = $this->_post('mobile');
        $smscode = $this->_post('smscode');
        $smscodebindmobile = $this->ajaxcheck('smscodebindmobile');
        if ($smscodebindmobile['value'] != $mobile || !$smscodebindmobile['valid']) {
            $this->error('手机号码验证错误或已失效');
        }
        if (!$this->smscheck($smscode)) {
            $this->error('手机验证码错误');
        }
        import('@.ORG.Util.SMS');
        $sent = SMS::send($mobile, "钱多多手机APP下载地址：{$url}");
        if ($sent) {
            $this->ajaxcheck('smscodebindmobile', array('value' => '', 'valid' => false, 'msg' => '手机验证码已失效'));
            $this->success('下载短信已发送至您的手机');
        } else {
            $this->error('短信发送失败（' . SMS::$errcode . '），请联系客服或重试');
        }
    }

    //手机短信获得APK下载链接
    public function getqianlinksms()
    {
        $url = 'http://dwz.cn/BL4L7';
        $mobile = $this->_post('mobile');
        $smscode = $this->_post('smscode');
        $smscodebindmobile = $this->ajaxcheck('smscodebindmobile');
        if ($smscodebindmobile['value'] != $mobile || !$smscodebindmobile['valid']) {
            $this->error('手机号码验证错误或已失效');
        }
        if (!$this->smscheck($smscode)) {
            $this->error('手机验证码错误');
        }
        import('@.ORG.Util.SMS');
        $sent = SMS::send($mobile, "钱多多手机APP下载地址：{$url}");
        if ($sent) {
            $this->ajaxcheck('smscodebindmobile', array('value' => '', 'valid' => false, 'msg' => '手机验证码已失效'));
            $this->success('下载短信已发送至您的手机');
        } else {
            $this->error('短信发送失败（' . SMS::$errcode . '），请联系客服或重试');
        }
    }

    //切换版本
    public function switchversion()
    {
        if ($this->_post('t') == '2014') {
            $_SESSION['theme_name'] = '201401';
        }
        if ($this->_post('t') == '2015') {
            $_SESSION['theme_name'] = '2015';
        }
        return true;
    }

    //广告跳转
    public function adrede()
    {
        header("Location:http://" . DOMAIN_URI);
    }

    public function ad_init()
    {
    }


    const ANSWER_STATUS_NAME_PRE = 'answer:status:memberid:';

    /**
     * $map
     * 获取最新的用户回复状态
     * @link http://d.com.net/public/get_answer_mine_status?memberid=2222305&ids=1212,18759
     *
     * {
     * "status": 1,
     * "info": "",
     * "data": {
     * "len": 1,
     * "list": {
     * "1212": false,
     * "18759": "1"
     * }
     * },
     * "page": null,
     * "msg": ""
     * }
     */
    public function get_answer_mine_status()
    {
        $list = [];
        $len = 0;
        $memberid = (int)$this->_request('memberid');
        $ids = array_map(function ($id) {
            return (int)$id;
        }, (array)explode(',', $this->_request('ids')));

        if ($memberid > 0) {
            $redis = $this->redis_cache_connect();
            $key = self::ANSWER_STATUS_NAME_PRE . "{$memberid}";
            //获取最近回复数量
            $len = (int)$redis->hLen($key);
            if (!empty($ids)) {
                $list = $redis->hMGet($key, $ids);
            }
        }

        $this->ajaxReturn([
            'len'  => $len,
            'list' => (object)$list,
        ]);
    }

    /**
     * @link http://d.com.net/public/get_answer_mine_status_by_memberid
     */
    public function get_answer_mine_status_by_memberid()
    {
        $list = [];
        $len = 0;
        $memberid = (int)0;
        $webcache_logined_memberid = $this->redis_cache->get('webcache_logined_memberid_' . session_id());
        $webcache_logined_memberid_arr = unserialize($webcache_logined_memberid);
        if (!empty($webcache_logined_memberid_arr['memberid'])) {
            $memberid = (int)$webcache_logined_memberid_arr['memberid'];
        }
        $ids = array_map(function ($id) {
            return (int)$id;
        }, (array)explode(',', $this->_request('ids')));

        if ($memberid > 0) {
            $redis = $this->redis_cache_connect();
            $key = self::ANSWER_STATUS_NAME_PRE . "{$memberid}";
            //获取最近回复数量
            $len = (int)$redis->hLen($key);
            if (!empty($ids)) {
                $list = $redis->hMGet($key, $ids);
            }
        }

        $this->ajaxReturn([
            'len'  => $len,
            'list' => (object)$list,
        ]);
    }

    /**
     * @link http://d.com.net/public/unset_answer_mine_status?memberid=2222305&ids=1212,18759
     */
    public function unset_answer_mine_status()
    {
        $list = [];
        $len = 0;
        $memberid = (int)$this->_request('memberid');
        $ids = array_map(function ($id) {
            return (int)$id;
        }, (array)explode(',', $this->_request('ids')));

        if ($memberid > 0) {
            $redis = $this->redis_cache_connect();
            $key = self::ANSWER_STATUS_NAME_PRE . "{$memberid}";
            if (!empty($ids)) {
                foreach ($ids as $id) {
                    $redis->hDel($key, $id);
                }
            }
        }

        $this->ajaxReturn();
    }
    //前台存管账户开户弹窗，关闭弹窗后，一段时间之内不再显示
    public function popCgOpenaccount(){
        $req_type = $this->_post('req_type');
        if ($req_type == 'login_close') {
            $_SESSION['member']['show_pop_cg_openaccount'] = 'no';
            return $this->ajaxSuccess('ok');
        }
    }
    //前台设置交易密码弹窗，关闭弹窗后，一段时间之内不再显示
    public function layerCgpwd(){
        $layer_hide = $this->_post('layer_type');
        if ($layer_hide == 'box_close') {
            $_SESSION['member']['show_layer'] = 'no';
            return $this->ajaxSuccess('ok');
        }
    }
    //前台逾期债权转让弹窗，关闭弹窗后，一段时间之内不再显示
    public function overdueTransfer()
    {
        $trans_type = $this->_post('trans_type');
        if ($trans_type == 'trans_close') {
            $_SESSION['member']['show_transfer'] = 'no';
            return $this->ajaxSuccess('ok');
        }
    }

    /*
     * 兑付方案
     */
    public function showdffa(){
        $this->display('News:show_dffa');
    }

    /**
     * 催收建议-显示页面
     */
    public function suggest(){
        $this->checkLogin();
        $input_max_length = 300; //最多输入字数限制
        $this->assign('input_max_length', $input_max_length);
        $this->display();
    }

    /**
     * ajax添加催收建议
     */
    public function ajax_add_suggest(){
        //get param
        $content = urldecode($this->_post('content'));

        //判断是否登陆
        $logined = $this->checkLogin(true);
        if ($logined === false){
            return $this->ajaxError('请先登陆！');
        }

        //调用newservice接口
        $param = array();
        $param['action'] = 'collect_feedback';
        $param['memberid'] = $this->member['id'];
        $param['content'] = $content;
        $result = $this->requestServiceApi('settle_suggest', $param);
        if ($result['code'] == 0) {
            $this->ajaxSuccess($result['msg']);
        } else {
            $this->ajaxError($result['msg']);
        }
    }

}

?>
